# 自动收集所有.cpp和.h文件（递归子目录）
file(GLOB_RECURSE SOURCES  "*.cpp" "*.c")
file(GLOB_RECURSE HEADERS  "*.h" "*.hpp")

message(STATUS "🍭actuator_module 开始构建")

add_library(actuator_module STATIC ${SOURCES})

target_include_directories(actuator_module PUBLIC 
  ${CMAKE_CURRENT_SOURCE_DIR}/  #添加当前文件目录
  ${CMAKE_SOURCE_DIR}/config   # 访问根目录生成的Config.h
)

target_link_libraries(actuator_module PUBLIC yj_common_module)
target_link_libraries(actuator_module PUBLIC rs485_module)
target_link_libraries(actuator_module PUBLIC agile_modbus_module)

# 链接libgoogle-glog库
find_library(GLOG_LIBRARY NAMES glog)
if(NOT GLOG_LIBRARY)
    message(FATAL_ERROR "glog library not found. Please install libgoogle-glog-dev package")
endif()


target_link_libraries(actuator_module
    PRIVATE
    ${GLOG_LIBRARY}
)

# 显式链接线程库
target_link_libraries(actuator_module PUBLIC Threads::Threads)
# 若需要进一步传递 -lrt 给依赖此库的可执行文件
target_link_options(actuator_module PUBLIC -lrt)

# add_executable(code_scan_test ./code_scan_test.cpp ${HEADERS})
# # 添加公共头文件路径
# target_include_directories(code_scan_test PRIVATE
#     ${CMAKE_CURRENT_BINARY_DIR}/include
#     ${CMAKE_CURRENT_BINARY_DIR}/
#     ${CMAKE_SOURCE_DIR}/config)
    
# target_link_libraries(code_scan_test PRIVATE actuator_module)

# add_executable(modbus_led_test ./modbus_led_test.cpp ${HEADERS})
# # 添加公共头文件路径
# target_include_directories(modbus_led_test PRIVATE
#     ${CMAKE_CURRENT_BINARY_DIR}/include
#     ${CMAKE_CURRENT_BINARY_DIR}/
#     ${CMAKE_SOURCE_DIR}/config)
    
# target_link_libraries(modbus_led_test PRIVATE actuator_module)

# add_executable(lk_motor_test ./lk_motor_test.cpp ${HEADERS})
# # 添加公共头文件路径
# target_include_directories(lk_motor_test PRIVATE
#     ${CMAKE_CURRENT_BINARY_DIR}/include
#     ${CMAKE_CURRENT_BINARY_DIR}/
#     ${CMAKE_SOURCE_DIR}/config)
    
# target_link_libraries(lk_motor_test PRIVATE actuator_module)

# add_executable(zdt_motor_test ./zdt_motor_test.cpp ${HEADERS})
# # 添加公共头文件路径
# target_include_directories(zdt_motor_test PRIVATE
#     ${CMAKE_CURRENT_BINARY_DIR}/include
#     ${CMAKE_CURRENT_BINARY_DIR}/
#     ${CMAKE_SOURCE_DIR}/config)
    
# target_link_libraries(zdt_motor_test PRIVATE actuator_module)

# add_executable(tjc_screen_test ./tjc_screen_test.cpp ${HEADERS})
# # 添加公共头文件路径
# target_include_directories(tjc_screen_test PRIVATE
#     ${CMAKE_CURRENT_BINARY_DIR}/include
#     ${CMAKE_CURRENT_BINARY_DIR}/
#     ${CMAKE_SOURCE_DIR}/config)
    
# target_link_libraries(tjc_screen_test PRIVATE actuator_module)


